package com.yoomiito.app.widget

import android.content.Context
import androidx.recyclerview.widget.RecyclerView
import android.view.Gravity
import android.view.View
import android.view.ViewGroup
import android.widget.PopupWindow
import com.yoomiito.app.R
import com.yoomiito.app.base.App
import com.yoomiito.app.utils.ColorUtils
import com.yoomiito.app.utils.DensityUtil
import com.yoomiito.app.utils.L
import com.yoomiito.app.utils.ResUtil

class FormatPopupWindow(val context: Context, view: View, layoutManager: androidx.recyclerview.widget.RecyclerView.LayoutManager, adapter: androidx.recyclerview.widget.RecyclerView.Adapter<androidx.recyclerview.widget.RecyclerView.ViewHolder>)
    : PopupWindow(context) {

    init {
        val location = IntArray(2)
        view.getLocationOnScreen(location)
        val y = location[1]+view.measuredHeight
        val rcy = androidx.recyclerview.widget.RecyclerView(context)
        rcy.background = ColorUtils.gradientAndRadius("#ffffff","#ffffff",0f,0f,20f,20f)
        rcy.setPadding(DensityUtil.dp2px(15f), DensityUtil.dp2px(20f), DensityUtil.dp2px(15f), DensityUtil.dp2px(20f))
        rcy.layoutManager = layoutManager
        rcy.adapter = adapter
        rcy.measure(View.MeasureSpec.UNSPECIFIED,View.MeasureSpec.UNSPECIFIED)
        width = App.mWidthPx
        height = ViewGroup.LayoutParams.WRAP_CONTENT
        contentView = rcy
        isOutsideTouchable = true
        isTouchable = true
        isFocusable = true
        setBackgroundDrawable(ResUtil.getDrawable(R.color.color_tran))
        showAsDropDown(view)
    }
}